Skip to content

Conversation

nnethercote
Copy link
Contributor

A bunch of cleanups I made while reading over this crate.

r? @lqd

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 28, 2024
@nnethercote nnethercote force-pushed the rustc_borrowck-cleanups branch from f3ad954 to 41c968e Compare October 29, 2024 03:40
@nnethercote nnethercote marked this pull request as ready for review October 29, 2024 03:41
@nnethercote
Copy link
Contributor Author

I've removed the commits you didn't like, should be good to go now.

@voidc
Copy link
Contributor

voidc commented Oct 29, 2024

Reducing the visibility of items in this crate might break tools using the get_body_with_borrowck_facts API. In #111840, some types and methods were deliberately made public, so that they could be used externally.

@nnethercote nnethercote force-pushed the rustc_borrowck-cleanups branch from 41c968e to b4fca11 Compare October 29, 2024 20:06
@nnethercote
Copy link
Contributor Author

visibility of items

I checked. Nothing in the consumers.rs file was changed. I thought that file contained the entire public API, but I found there are a few items outside that file marked with a comment as being in the API. I have reverted the visibility changes to those items. Should be good to go now, thanks.

@lqd
Copy link
Member

lqd commented Oct 29, 2024

as they’ve already started reviewing, r? compiler-errors

@rustbot rustbot assigned compiler-errors and unassigned lqd Oct 29, 2024
@bors
Copy link
Collaborator

bors commented Oct 30, 2024

☔ The latest upstream changes (presumably #132349) made this pull request unmergeable. Please resolve the merge conflicts.

@nnethercote nnethercote force-pushed the rustc_borrowck-cleanups branch from b4fca11 to 0bcd936 Compare October 31, 2024 04:25
@nnethercote
Copy link
Contributor Author

@compiler-errors: I rebased, ready for review again, thanks.

@compiler-errors
Copy link
Member

r=me after rebasing

So they're all in the one place. Also prepend with `crate::`, à la the
`unqualified_local_imports` lint.
Mostly by wrapping overly long comment lines, plus a few other things.
It's strange to have a struct that contains a single anonymous field
that is an enum. This commit merges them. This does require increasing
the visibility of `TypeOfInfo` to `pub(crate)`, but that seems
worthwhile.
Because there is no real reason for it to be a separate struct.
- It has no methods.
- It's easy to confuse with the nearby `BorrowckInferContext` (which
  does have methods).
- The `mut` ref to it in `TypeChecker` makes it seem like any of the
  fields within might be mutable, but only two (`all_facts` and
  `constraints`) actually are.
- Two of the fields are `pub(crate)` but can be private.

This change makes a lot of code more concise and readable.
It has four different `insert` methods, with some duplication. This
commit finds the commonality and removes them all.
- Store a mut ref to a `BorrowckDiags` in `MirBorrowckCtxt` instead of
  owning it, to save having to pass ownership in and out of
  `promoted_mbcx`.
- Use `buffer_error` in a couple of suitable places.
@nnethercote nnethercote force-pushed the rustc_borrowck-cleanups branch from 0bcd936 to e0e7a43 Compare November 4, 2024 06:36
@nnethercote
Copy link
Contributor Author

@bors r=compiler-errors

@bors
Copy link
Collaborator

bors commented Nov 4, 2024

📌 Commit e0e7a43 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 4, 2024
@bors
Copy link
Collaborator

bors commented Nov 4, 2024

⌛ Testing commit e0e7a43 with merge ca87b53...

@bors
Copy link
Collaborator

bors commented Nov 4, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing ca87b53 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 4, 2024
@bors bors merged commit ca87b53 into rust-lang:master Nov 4, 2024
7 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 4, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ca87b53): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary -2.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 779.582s -> 779.908s (0.04%)
Artifact size: 335.21 MiB -> 335.29 MiB (0.03%)

@nnethercote nnethercote deleted the rustc_borrowck-cleanups branch November 4, 2024 22:56
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 15, 2024
…2, r=<try>

`rustc_borrowck` cleanups, part 2

The code under `do_mir_borrowck` is pretty messy, especially the various types like `MirBorrowckCtxt`, `BorrowckInferCtxt`, `MirTypeckResults`, `MirTypeckRegionConstraints`, `CreateResult`, `TypeChecker`, `TypeVerifier`, `LivenessContext`, `LivenessResults`. This PR does some tidying up, though there's still plenty of mess left afterwards.

A sequel to rust-lang#132250.

r? `@compiler-errors`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 18, 2024
…2, r=<try>

`rustc_borrowck` cleanups, part 2

The code under `do_mir_borrowck` is pretty messy, especially the various types like `MirBorrowckCtxt`, `BorrowckInferCtxt`, `MirTypeckResults`, `MirTypeckRegionConstraints`, `CreateResult`, `TypeChecker`, `TypeVerifier`, `LivenessContext`, `LivenessResults`. This PR does some tidying up, though there's still plenty of mess left afterwards.

A sequel to rust-lang#132250.

r? `@compiler-errors`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 19, 2024
…2, r=Nadrieril

`rustc_borrowck` cleanups, part 2

The code under `do_mir_borrowck` is pretty messy, especially the various types like `MirBorrowckCtxt`, `BorrowckInferCtxt`, `MirTypeckResults`, `MirTypeckRegionConstraints`, `CreateResult`, `TypeChecker`, `TypeVerifier`, `LivenessContext`, `LivenessResults`. This PR does some tidying up, though there's still plenty of mess left afterwards.

A sequel to rust-lang#132250.

r? `@compiler-errors`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants